package cn.hairui.blog.service;

import cn.hairui.blog.dao.ArticalMapper;
import cn.hairui.blog.entity.Artical;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author laoganbu
 * @since 2020-04-06
 */
@Service(value = "articalService")
public class ArticalServiceImpl extends ServiceImpl<ArticalMapper, Artical> implements ArticalService {

    @Autowired
    private ArticalMapper articalMapper;

    @Override
    public List<Artical> listTop(int count, String key) {
        return articalMapper.listTop(count, key);
    }

    @Override
    public int count() {
        return articalMapper.count();
    }

    @Override
    public List<Map> selectByShowFlag(String showFlag) {
        return articalMapper.selectByShowFlag(showFlag);
    }

    @Override
    public List<Map> selectByAccount(String account) {
        return articalMapper.selectByAccount(account);
    }

    @Override
    public int add(Artical artical) {
        articalMapper.insert(artical);
        return artical.getId();
    }

    @Override
    public List<Map> selectByShowFlagTypeId(String showFlag, int typeId) {
        return articalMapper.selectByShowFlagTypeId(showFlag, typeId);
    }

    @Override
    public List<Map> selectByShowFlagTagId(String showFlag, int tagId) {
        return articalMapper.selectByShowFlagTagId(showFlag, tagId);
    }

    @Override
    public List<Map> selectYearAndCount(String showFlag) {
        return articalMapper.selectYearAndCount(showFlag);
    }

    @Override
    public List<Artical> selectByYearAndShowFlag(String year, String showFlag, int count) {
        return articalMapper.selectByYearAndShowFlag(year, showFlag, count);
    }

    @Override
    public List<Map> selectByShowFlagAndYear(String showFlag, int year) {
        return articalMapper.selectByShowFlagAndYear(showFlag, year);
    }

    @Override
    public Artical findLastArtical(int id) {
        return articalMapper.findLastArtical(id);
    }

    @Override
    public Artical findNextArtical(int id) {
        return articalMapper.findNextArtical(id);
    }

    @Override
    public void updateLVTimesById(int id, int liketimes, int viewtimes) {
        articalMapper.updateLVTimesById(id,liketimes,viewtimes);
    }
}
